<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
//            相同的字段
            $table->string('source')->nullable()->comment('订单来源');
            $table->string('phone')->nullable()->comment('手机号');
            $table->string('wx_name')->nullable()->comment('微信名称');
            $table->string('position')->nullable()->comment('取车经纬度');
            $table->string('return_position')->nullable()->comment('还车经纬度');
            $table->longText('drink')->nullable()->comment('随车饮料');
            $table->decimal('lease_price',10,2)->default(0.00)->comment('租金');
            $table->timestamp('pre_fetch_time')->nullable()->comment('预取车时间');
            $table->timestamp('pre_return_time')->nullable()->comment('预还车时间');
            $table->float('rate',10,2)->default(0.00)->comment('折扣率');
            $table->string('deposit',)->nullable()->comment('押金');
            $table->string('break_rules',)->nullable()->comment('违章押金');
            $table->decimal('total',10,2)->default(0.00)->comment('预付总金额');
            $table->integer('car_id')->default(0)->comment('车系id');
            $table->string('name')->nullable()->comment('车辆名称');
            $table->string('openid')->default(0)->comment('用户openid');
            //差别字段

            $table->decimal('fact_total',10,2)->default(0.00)->comment('实际总金额');

            //没有的字段
//            $table->decimal('fact_lease_price')->default(0.00)->comment('实际租车价格');
            $table->integer('gear_car_id')->default(0)->comment('安排车辆id');
            $table->string('gear_car_name')->nullable()->comment('排车车名');
            $table->string('order_sn')->nullable()->comment('订单编号');
            $table->dateTime('pay_time')->nullable()->comment('下单时间');
            $table->string('car_category')->nullable()->comment('车型名称');
            $table->decimal('base_price',10,2)->default(0.00)->comment('基础价格');
            $table->decimal('brokerage',10,2)->default(0.00)->comment('手续费');
            $table->string('car_series')->nullable()->comment('精选服务字符串');
            $table->integer('pre_lease_days')->default(0)->comment('预租车时长');
            $table->timestamp('send_car_time')->nullable()->comment('排车时间');
            $table->timestamp('fetch_time')->nullable()->comment('实际取车时间');
            $table->timestamp('return_time')->nullable()->comment('实际还车时间');
            $table->integer('lease_days')->default(0)->comment('实际租车时长');
            $table->tinyInteger('status')->default(0)->comment('订单状态 -1:客户取消订单,0:已经下单未付款,1:已下单未发货,2:已下单已发货,3:已下单已经完成发货,4:商家取消订单,5:订单完成,6:订单超时');
            $table->string('license')->nullable()->comment('车牌');
            $table->string('send_user')->nullable()->comment('送车人电话');
            $table->string('payType')->default('minipay')->comment('支付类型');
            $table->string('out_trade_no')->nullable()->comment('自定义商户号');

            $table->string('return_address')->nullable()->comment('还车地址');
            $table->string('fetch_address')->nullable()->comment('取车地址');
            $table->string('city')->nullable()->comment('城市');
            $table->tinyInteger('is_coupon')->default(0)->comment('是否启用优惠券');
            $table->integer('coupon_id')->default(0)->comment('优惠券id');
            $table->decimal('coupon_price')->default(0.00)->comment('优惠券面额');

            $table->integer('pre_hours')->default(0)->comment('小时');
            $table->integer('fetch_hours')->default(0)->comment('实际小时');


            $table->decimal('pre_base_price_total',10,2)->default(0.00)->comment('优惠前基本保障费');
            $table->decimal('pre_brokerage_total',10,2)->default(0.00)->comment('优惠前车辆整备费');

            $table->decimal('pre_lease_price_total',10,2)->default(0.00)->comment('优惠前租金');
            $table->decimal('pre_total',10,2)->default(0.00)->comment('优惠前共计');

            $table->decimal('bc_base_price_total',10,2)->default(0.00)->comment('优惠后基本保障费');
            $table->decimal('bc_brokerage_total',10,2)->default(0.00)->comment('优惠后车辆整备费');

            $table->decimal('bc_lease_price_total',10,2)->default(0.00)->comment('优惠后租金');
            $table->decimal('bc_total',10,2)->default(0.00)->comment('优惠后共计');


            $table->decimal('fact_base_price_total',10,2)->default(0.00)->comment('实际基本保障费');
            $table->decimal('fact_brokerage_total',10,2)->default(0.00)->comment('实际车辆整备');


            $table->decimal('fact_lease_price_total',10,2)->default(0.00)->comment('实际租金');


            $table->string('send_mileage')->nullable()->comment('送车公里数');
            $table->string('get_mileage')->nullable()->comment('取车公里数');
            $table->text('sundry_fee')->nullable()->comment('其它费用');
            $table->string('nickname')->nullable()->comment('昵称');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('mark')->nullable()->comment('头像');


            $table->decimal('service_price',10,2)->default(0.00)->comment('精选服务');

            $table->longText('fact_service_list')->nullable()->comment('所有服务列表');
            $table->string('service')->nullable()->comment('精选服务');
            $table->decimal('fact_service_total',10,2)->default(0.00)->comment('实际精选服务');

            $table->decimal('pre_service_total',10,2)->default(0.00)->comment('优惠前精选服务');
            $table->decimal('bc_service_total',10,2)->default(0.00)->comment('优惠后精选服务');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
